package array;

public class leetCode34_searchRange {
    public static void main(String[] args) {
        int[] a = {1};
        int target = 1;
        leetCode34_searchRange m = new leetCode34_searchRange();
        int[] ints = m.searchRange(a, target);
        System.out.println(1);;
    }
    public int[] searchRange(int[] nums, int target) {
       if(nums == null || nums.length == 0) return new int[]{-1,-1};
       if(nums.length == 1 && nums[0] == target){
           return new int[]{0,0};
       }
       int left = 0;
       int right = nums.length - 1;
       int[] result = {-1,-1};
       while (left <= right) {
           if (nums[left] != target) {
               left++;
           }else{
               result[0] = left;
               break;
           }

       }
       while (left <= right) {
           if(nums[right] != target){
               right--;
           }else{
               result[1] = right;
               break;
           }
       }
       return result;
    }



}
